Skip to content

[ENH] Add test to validate execution of README Python examples#713

Merged
fkiraly merged 3 commits intoPyPortfolio:mainfrom
PredictiveManish:Test-README
Mar 8, 2026
Merged

[ENH] Add test to validate execution of README Python examples#713
fkiraly merged 3 commits intoPyPortfolio:mainfrom
PredictiveManish:Test-README

Conversation

@PredictiveManish
Copy link
Contributor

Adds a pytest that parses README.md and executes all python code blocks to ensure examples remain valid.

Closes #669

  • Uses regex to extract Python blocks
  • Executes them sequentially in a shared namespace (since examples are stateful)
  • Runs from repo root so relative paths like tests/resources/... resolve correctly
  • Adds repo root to sys.path so pypfopt can be imported without installation

This verifies that README examples run as documented and helps prevent regressions in imports or usage.

@fkiraly fkiraly added the enhancement New feature or request label Feb 27, 2026
@PredictiveManish
Copy link
Contributor Author

PredictiveManish commented Feb 27, 2026

The extra file changes occurred when I started working on the CI failure issue, as Ruff auto-formatting modified some files.

and as it's not any logic break or any particular change so I added them here.

@fkiraly fkiraly merged commit 63e8268 into PyPortfolio:main Mar 8, 2026
39 checks passed
@PredictiveManish
Copy link
Contributor Author

Thanks @fkiraly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENH] add tests for correctness of code in README

2 participants